<!DOCTYPE html>
<html lang="zh-CN">


<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="author" content="viggo" />
  <title>MrLiu的博客 - </title>
  <meta name="keywords" content="">
  <meta name="description" content="">
  <link rel="shortcut icon" href="/static/favicon.ico">
  <link rel="stylesheet" href="/css/github.min.css">
  <script src="/js/highlight.min.js"></script>
  
<link rel="stylesheet" href="//fonts.loli.net/css?family=Arimo:400,700,400italic.css">
<link rel="stylesheet" href="/css/fonts/linecons/css/linecons.min.css">
<link rel="stylesheet" href="/css/fonts/fontawesome/css/all.min.css">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/xenon-core.min.css">
<link rel="stylesheet" href="/css/xenon-components.min.css">
<link rel="stylesheet" href="/css/xenon-skins.min.css">
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/css/nav.min.css">
<link rel="stylesheet" href="/css/md.css">

  
<script src="/js/jquery-1.11.1.min.js"></script>

  
<script src="/js/header.js"></script>

  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
        
<script src="/js/html5shiv.min.js"></script>

        
<script src="/js/respond.min.js"></script>

    <![endif]-->
  <script>
  hljs.configure({useBR: true});
  hljs.initHighlightingOnLoad();
  </script>
  <!-- / FB Open Graph -->
  <meta property="og:type" content="article">
  <meta property="og:url" content="https://liu-meizhou.github.io/js%E5%8E%9F%E5%9E%8B%E9%93%BE/index.html">
  <meta property="og:title" content="MrLiu的博客 - ">
  <meta property="og:description" content="">
  <meta property="og:site_name" content="MrLiu的博客 - ">
  
  <meta property="og:image" content="/images/webstack_banner_cn.png">
  
  <!-- / Twitter Cards -->
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="MrLiu的博客 - ">
  <meta name="twitter:description" content="">
  
  <meta name="twitter:image" content="/images/webstack_banner_cn.png">
  
<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div class="page-container">
    <div class="sidebar-menu toggle-others fixed">
  <div class="sidebar-menu-inner">
    <header class="logo-env">
      <div class="logo">
        <a href="/index.html" class="logo-expanded">
          <img src="/images/logo@2x.png" width="100%" alt="" />
        </a>
        <a href="/index.html" class="logo-collapsed">
          <img src="/images/logo-collapsed@2x.png" width="40" alt="" />
        </a>
      </div>
      <div class="mobile-menu-toggle visible-xs">
        <a href="#" data-toggle="user-info-menu">
          <i class="linecons-cog"></i>
        </a>
        <a href="#" data-toggle="mobile-menu">
          <i class="fas fa-bars"></i>
        </a>
      </div>
    </header>
    <ul id="main-menu" class="main-menu">
      

      
        <li><a href="#如何探索" class="smooth" style="padding-left: 0em" title="如何探索"><i class="far fa-star"></i><span class="title">如何探索</span></a></li><li><a href="#结构图" class="smooth" style="padding-left: 0em" title="结构图"><i class="far fa-star"></i><span class="title">结构图</span></a></li><li><a href="#Object" class="fas fa-angle-down" style="cursor: pointer; padding-left: 0em" title="Object"><i class="far fa-star"></i><span class="title">Object</span></a><ul><li><a href="#属性" class="smooth" style="padding-left: 1em" title="属性"><i class="far fa-star"></i><span class="title">属性</span></a></li><li><a href="#继承" class="fas fa-angle-down" style="cursor: pointer; padding-left: 1em" title="继承"><i class="far fa-star"></i><span class="title">继承</span></a><ul><li><a href="#String" class="smooth" style="padding-left: 2em" title="String"><i class="far fa-star"></i><span class="title">String</span></a></li><li><a href="#Array" class="fas fa-angle-down" style="cursor: pointer; padding-left: 2em" title="Array"><i class="far fa-star"></i><span class="title">Array</span></a><ul><li><a href="#属性-1" class="smooth" style="padding-left: 3em" title="属性"><i class="far fa-star"></i><span class="title">属性</span></a></li><li><a href="#修改器方法" class="smooth" style="padding-left: 3em" title="修改器方法"><i class="far fa-star"></i><span class="title">修改器方法</span></a></li><li><a href="#访问方法" class="smooth" style="padding-left: 3em" title="访问方法"><i class="far fa-star"></i><span class="title">访问方法</span></a></li><li><a href="#迭代方法" class="smooth" style="padding-left: 3em" title="迭代方法"><i class="far fa-star"></i><span class="title">迭代方法</span></a></li></ul></li><li><a href="#Function" class="fas fa-angle-down" style="cursor: pointer; padding-left: 2em" title="Function"><i class="far fa-star"></i><span class="title">Function</span></a><ul><li><a href="#属性-2" class="smooth" style="padding-left: 3em" title="属性"><i class="far fa-star"></i><span class="title">属性</span></a></li><li><a href="#Object-1" class="smooth" style="padding-left: 3em" title="Object()"><i class="far fa-star"></i><span class="title">Object()</span></a></li><li><a href="#Array-1" class="smooth" style="padding-left: 3em" title="Array()"><i class="far fa-star"></i><span class="title">Array()</span></a></li><li><a href="#String-1" class="smooth" style="padding-left: 3em" title="String()"><i class="far fa-star"></i><span class="title">String()</span></a></li></ul></li></ul></li></ul></li><li><a href="#总结" class="fas fa-angle-down" style="cursor: pointer; padding-left: 0em" title="总结"><i class="far fa-star"></i><span class="title">总结</span></a><ul><li><a href="#原型" class="smooth" style="padding-left: 1em" title="原型"><i class="far fa-star"></i><span class="title">原型</span></a></li><li><a href="#属性的修饰" class="smooth" style="padding-left: 1em" title="属性的修饰"><i class="far fa-star"></i><span class="title">属性的修饰</span></a></li><li><a href="#typeof原理" class="smooth" style="padding-left: 1em" title="typeof原理"><i class="far fa-star"></i><span class="title">typeof原理</span></a></li><li><a href="#instanceof原理" class="smooth" style="padding-left: 1em" title="instanceof原理"><i class="far fa-star"></i><span class="title">instanceof原理</span></a></li></ul></li>
      

      
      <li class="submit-tag">
        <a href="/author">
          <i class="far fa-heart"></i>
          <span class="tooltip-blue">关于作者</span>
        </a>
      </li>
      
      
      <li>
        <a href="javascript:void(0)">
          <i class="fas fa-eye"></i>
          <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span></span>
        </a>
      </li>
      <li>
        <a href="javascript:void(0)">
          <i class="fas fa-users"></i>
          <span id="busuanzi_container_site_uv">本站总访客数<span id="busuanzi_value_site_uv"></span></span>
        </a>
      </li>
      
    </ul>
  </div>
  <div class="e-resize"></div>
</div>

    <div class="main-content">
      <nav class="navbar user-info-navbar" role="navigation">
        <ul class="user-info-menu left-links list-inline list-unstyled">
          <li class="hidden-sm hidden-xs hover-line">
            <a href="#" data-toggle="sidebar">
              <i class="fas fa-bars"></i>
            </a>
          </li>
          <li class="dropdown hover-line language-switcher">
            <a href="/index.html" class="dropdown-toggle" data-toggle="dropdown">
              <img src="/images/flags/flag-cn.png" alt="flag-cn" /> Chinese
            </a>
            <ul class="dropdown-menu languages">
              <li class="active">
                <a href="/index.html">
                  <img src="/images/flags/flag-cn.png" alt="flag-cn" alt="flag-cn" /> Chinese
                </a>
              </li>
            </ul>
          </li>
          <li class="switch-mode hover-line" onclick="switchNightMode()">
            <a href="#">
              <svg t="1593061068148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1681" width="16" height="16">
                <path d="M582.4 326.4c-140.8 0-256 115.2-256 256s115.2 256 256 256 256-115.2 256-256-115.2-256-256-256z m0 448c-70.4 0-131.2-36.8-164.8-92.8 12.8 3.2 27.2 4.8 40 4.8 121.6 0 219.2-99.2 219.2-219.2 0-17.6-1.6-35.2-6.4-52.8 60.8 32 102.4 96 102.4 169.6 1.6 104-84.8 190.4-190.4 190.4zM582.4 262.4c17.6 0 32-14.4 32-32v-128c0-17.6-14.4-32-32-32s-32 14.4-32 32v128c0 17.6 14.4 32 32 32zM262.4 582.4c0-17.6-14.4-32-32-32h-128c-17.6 0-32 14.4-32 32s14.4 32 32 32h128c17.6 0 32-14.4 32-32zM310.4 356.8c6.4 6.4 14.4 9.6 22.4 9.6 8 0 16-3.2 22.4-9.6 12.8-12.8 12.8-32 0-44.8l-91.2-91.2c-12.8-12.8-32-12.8-44.8 0-12.8 12.8-12.8 32 0 44.8l91.2 91.2zM944 220.8c-12.8-12.8-32-12.8-44.8 0l-91.2 91.2c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 14.4 9.6 22.4 9.6 8 0 16-3.2 22.4-9.6l91.2-91.2c12.8-12.8 12.8-33.6 0-44.8zM310.4 808l-91.2 91.2c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 14.4 9.6 22.4 9.6 8 0 16-3.2 22.4-9.6l91.2-91.2c12.8-12.8 12.8-32 0-44.8-11.2-11.2-32-11.2-44.8 0z" p-id="1682" fill="#707070"></path>
              </svg>
            </a>
          </li>
        </ul>
        
        <a target="_blank" rel="noopener" href="https://github.com/liu-meizhou/liu-meizhou.github.io" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
        
      </nav>
      
<h1 id="如何探索"><a href="#如何探索" class="headerlink" title="如何探索"></a>如何探索</h1><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">&#x27;Boolean&#x27;</span>, <span class="hljs-keyword">new</span> <span class="hljs-built_in">Boolean</span>())<br><span class="hljs-built_in">console</span>.log(<span class="hljs-string">&#x27;Number&#x27;</span>, <span class="hljs-keyword">new</span> <span class="hljs-built_in">Number</span>())<br><span class="hljs-built_in">console</span>.log(<span class="hljs-string">&#x27;String&#x27;</span>, <span class="hljs-keyword">new</span> <span class="hljs-built_in">String</span>())<br><span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;a&quot;</span>.__proto__)<br><span class="hljs-built_in">console</span>.log(&#123;&#125;)<br><span class="hljs-built_in">console</span>.log([])<br><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params"></span>) </span>&#123;&#125;<br><span class="hljs-built_in">console</span>.log(<span class="hljs-string">&#x27;Function&#x27;</span>, f.prototype)<br></code></pre></td></tr></table></figure>

<h1 id="结构图"><a href="#结构图" class="headerlink" title="结构图"></a>结构图</h1><p><img src="../static/js%E5%8E%9F%E5%9E%8B%E9%93%BE.assets/image-20210620202132451.png" alt="image-20210620202132451"></p>
<h1 id="Object"><a href="#Object" class="headerlink" title="Object"></a>Object</h1><h2 id="属性"><a href="#属性" class="headerlink" title="属性"></a>属性</h2><ul>
<li>任何属性(包括不存在的属性)默认都为undefined</li>
<li><code>constructor</code>：构造函数<code>Function-Object()</code></li>
<li><code>hasOwnProperty</code>：检查该实例是否包含某个属性(不走原型链)<ul>
<li>输入：属性名<code>string</code></li>
<li>返回：是否存在<code>boolean</code></li>
</ul>
</li>
<li><code>isPrototypeOf</code>：检查该实例是否存在于另一对象的原型链上<ul>
<li>输入：对象<code>Object</code></li>
<li>返回：实例是否是<code>Object</code>原型链上的对象</li>
</ul>
</li>
<li><code>propertyIsEnumerable</code>：该对象的属性是否可在<code>for...in</code>中被枚举<ul>
<li>输入：属性名<code>string</code></li>
<li>返回：该属性是否可枚举<code>boolean</code></li>
</ul>
</li>
<li><code>toLocaleString</code>：调用<code>toString</code></li>
<li><code>toString</code>：返回<code>[object type]</code></li>
<li><code>valueOf</code>：返回对象本身</li>
</ul>
<h2 id="继承"><a href="#继承" class="headerlink" title="继承"></a>继承</h2><h3 id="String"><a href="#String" class="headerlink" title="String"></a>String</h3><h3 id="Array"><a href="#Array" class="headerlink" title="Array"></a>Array</h3><h4 id="属性-1"><a href="#属性-1" class="headerlink" title="属性"></a>属性</h4><ul>
<li><code>length</code>：数组长度</li>
</ul>
<h4 id="修改器方法"><a href="#修改器方法" class="headerlink" title="修改器方法"></a>修改器方法</h4><ul>
<li><code>copyWithin</code>：在原数组上进行复制</li>
</ul>
<h4 id="访问方法"><a href="#访问方法" class="headerlink" title="访问方法"></a>访问方法</h4><h4 id="迭代方法"><a href="#迭代方法" class="headerlink" title="迭代方法"></a>迭代方法</h4><ul>
<li><code>concat</code></li>
<li><code>entries</code></li>
<li><code>every</code></li>
<li><code>fill</code></li>
<li><code>filter</code></li>
<li><code>find</code></li>
<li><code>findIndex</code></li>
<li><code>flat</code></li>
<li><code>flatMap</code></li>
<li><code>forEach</code></li>
<li><code>includes</code></li>
<li><code>indexOf</code></li>
<li><code>join</code></li>
<li><code>keys</code></li>
<li><code>values</code></li>
<li><code>lastIndexOf</code></li>
<li><code>map</code></li>
<li><code>pop</code></li>
<li><code>push</code></li>
<li><code>reduce</code></li>
<li><code>reduceRight</code></li>
<li><code>reverse</code></li>
<li><code>shift</code></li>
<li><code>unshift</code></li>
<li><code>slice</code></li>
<li><code>some</code></li>
<li><code>sort</code></li>
<li><code>splice</code></li>
<li><code>toLocaleString</code></li>
<li><code>toString</code></li>
</ul>
<h3 id="Function"><a href="#Function" class="headerlink" title="Function"></a>Function</h3><h4 id="属性-2"><a href="#属性-2" class="headerlink" title="属性"></a>属性</h4><ul>
<li><code>arguments</code>：保存参数的类数组对象，是<code>Function.arguments浅拷贝对象</code> <code>ES6使用剩余参数更好,他是个数组对象</code><ul>
<li><code>callee</code>：指向调用的函数</li>
<li><code>length</code>：传入参数的个数</li>
</ul>
</li>
<li><code>caller</code>：调用该函数的函数，为<code>null</code>表示全局调用</li>
<li><code>constructor</code>：构造函数<code>Function-Function()</code></li>
<li><code>length</code>：参数个数</li>
<li><code>name</code>：函数名</li>
<li><code>call</code>：第一个参数传入调用该函数的<code>this</code>对象，后面参数正常传参就好</li>
<li><code>apply</code>：同<code>call</code>，不同于只有两个参数，第二个参数传入数组或类数组对象</li>
<li><code>bind</code>：同<code>call</code>，不同于该函数属于新创建</li>
<li><code>toString</code>：打印函数内容</li>
</ul>
<h4 id="Object-1"><a href="#Object-1" class="headerlink" title="Object()"></a>Object()</h4><ul>
<li><p><code>length</code>：值为1</p>
</li>
<li><p><code>name</code></p>
</li>
<li><p><code>prototype</code>：构造函数的原型类型<code>由该构造函数构造出来的对象默认原型对象，该对象处于Object下，名字也为Object</code></p>
</li>
<li><p><code>assign</code>：通过一个或多个对象，使用复制来创建一个新对象</p>
<ul>
<li>输入：一个或多个对象<code>target, ...sources: Object</code></li>
<li>输出：目标对象<code>遍历输入对象，枚举对象属性，进行复制到目的对象上</code></li>
</ul>
</li>
<li><p><code>create</code>：通过指定原型对象和对象创建一个新对象</p>
<ul>
<li>输入：原型，对象<code>proto, [propertiesObject]: Object</code></li>
<li>返回：拥有<code>propertiesObject</code>属性且原型指向<code>proto</code>的新对象</li>
</ul>
</li>
<li><p><code>defineProperty</code>：给对象中的属性 添加/修改 配置</p>
<ul>
<li>输入：对象<code>obj:Object</code>，属性<code>prop:String</code>，该属性的修饰<code>descriptor:Object</code><ul>
<li>属性的修饰：<a href="##%E5%B1%9E%E6%80%A7%E7%9A%84%E4%BF%AE%E9%A5%B0">看总结</a></li>
</ul>
</li>
<li>返回：<code>obj</code></li>
</ul>
</li>
<li><p><code>defineProperties</code>：给对象中多个属性 添加/修改 配置</p>
<ul>
<li><p>输入：对象<code>obj</code>，属性配置<code>props:Object</code></p>
<ul>
<li><p><code>props</code>的结构</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs javascript">&#123;<br>  <span class="hljs-string">&#x27;property1&#x27;</span>: &#123;<br>    value: <span class="hljs-literal">true</span>,<br>    writable: <span class="hljs-literal">true</span><br>  &#125;,<br>  <span class="hljs-string">&#x27;property2&#x27;</span>: &#123;<br>    value: <span class="hljs-string">&#x27;Hello&#x27;</span>,<br>    writable: <span class="hljs-literal">false</span><br>  &#125;<br>&#125;<br></code></pre></td></tr></table></figure></li>
</ul>
</li>
<li><p>返回：<code>obj</code></p>
</li>
</ul>
</li>
<li><p><code>getOwnPropertySymbols</code>：传入对象返回该对象<code>key为Symbol</code>的数组</p>
</li>
<li><p><code>getOwnPropertyNames</code>：传入对象返回该对象可枚举和不可枚举的Keys数组</p>
</li>
<li><p><code>keys</code>：传入对象返回对象自身可枚举属性名称的数组</p>
</li>
<li><p><code>values</code>：传入对象返回对象自身可枚举属性名称对应值的数组</p>
</li>
<li><p><code>entries</code>：传入对象返回该对象自身可枚举的<code>[key, value]</code>数组</p>
</li>
<li><p><code>fromEntries</code>：把<code>[key, value]</code>可迭代<code>Array、Map</code>对象转化成<code>Object</code></p>
</li>
<li><p><code>getOwnPropertyDescriptor</code>：传入对象及其属性名，返回该属性的配置</p>
</li>
<li><p><code>getOwnPropertyDescriptors</code>：传入对象及其属性数组，返回属性们的配置</p>
</li>
<li><p><code>getPrototypeOf</code>：传入对象，返回该对象的原型对象</p>
</li>
<li><p><code>setPrototypeOf</code>：传入对象和原型对象，设置该对象的原型为该原型对象</p>
<p>标准的函数，功能与直接调用<code>.__proto__=...</code>一致，都性能慢，不过这个是标准化函数</p>
</li>
<li><p><code>is</code>：传入<code>value1, value2</code>，返回比较是否相等</p>
<ul>
<li>与<code>==</code>运算<em>不同。</em> <code>==</code> 运算符在判断相等前对两边的变量(如果它们不是同一类型) 进行强制转换 (这种行为的结果会将 <code>&quot;&quot; == false</code> 判断为 <code>true</code>), 而 <code>Object.is</code>不会强制转换两边的值</li>
<li>与<code>===</code>运算也不相同。 <code>===</code> 运算符 (也包括 <code>==</code> 运算符) 将数字 <code>-0</code> 和 <code>+0</code> 视为相等 ，而将<code>Number.NaN</code>与<code>NaN</code>视为不相等</li>
</ul>
</li>
<li><p><code>isExtensible</code>：判断对象是否可扩展</p>
<ul>
<li>下面都是设置对象为不可扩展</li>
</ul>
</li>
<li><p><code>preventExtensions</code>：防止对象的任何扩展（也就是永远不能添加新属性）</p>
</li>
<li><p><code>seal</code>：防止对象的属性被删除</p>
</li>
<li><p><code>freeze</code>：冻结对象：其他代码不能删除或更改任何属性</p>
</li>
<li><p><code>isFrozen</code>：是否冻结</p>
</li>
<li><p><code>isSealed</code>：是否密封</p>
</li>
</ul>
<h4 id="Array-1"><a href="#Array-1" class="headerlink" title="Array()"></a>Array()</h4><ul>
<li><code>from</code>：从类数组对象或者可可迭代对象中创建一个新的数组实例（浅拷贝）</li>
<li><code>isArray</code>：判断一个变量是否为数组</li>
<li><code>of</code>：数组数组<code>...item</code>创建数组</li>
</ul>
<h4 id="String-1"><a href="#String-1" class="headerlink" title="String()"></a>String()</h4><h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p><strong>万事万物皆实例</strong></p>
<h2 id="原型"><a href="#原型" class="headerlink" title="原型"></a>原型</h2><p><strong>不要去修改对象的<code>__proto__</code>原型</strong></p>
<p>理由如下</p>
<ul>
<li>这种行为在每一个JavaScript引擎和浏览器中都是一个非常慢且影响性能的操作<ul>
<li>性能消耗的时间也不是简单的花费在 <code>obj.__proto__ = ...</code> 语句上</li>
<li>它还会影响到所有继承来自该 <code>[[Prototype]]</code> 的对象（<code>为什么会影响???想了半天没想明白</code>）</li>
</ul>
</li>
<li>创建一个新的且可以继承 <code>[[Prototype]]</code> 的对象，推荐使用 <strong><code>Object.create()</code></strong></li>
</ul>
<p>访问<code>.__proto__</code></p>
<ul>
<li><code>Object.getPrototypeOf(obj)</code></li>
<li><code>Reflect.getPrototypeOf(obj)</code></li>
</ul>
<p>设置<code>.__proto__</code>：性能依旧慢，但ES6之前这些都是存在于语言规范中</p>
<ul>
<li><code>Object.setPrototypeOf(obj)</code></li>
<li><code>Reflect.setPrototypeOf(obj)</code></li>
</ul>
<h2 id="属性的修饰"><a href="#属性的修饰" class="headerlink" title="属性的修饰"></a>属性的修饰</h2><p><strong>Object</strong>里目前存在的属性有 <em>数据描述符</em>、<em>存取描述符</em>，属性属性这两大类型(用<code>Object</code>描述)之一</p>
<ul>
<li>数据描述符：是一个具有值的属性，可写也可配置不可写：<code>默认</code></li>
<li>存取描述符是由<code>getter</code>函数和<code>setter</code>函数所描述的属性</li>
</ul>
<p><strong>共同属性</strong></p>
<ul>
<li><code>configurable</code>：该属性是否可配置、可删<code>delete</code>：默认<code>false</code></li>
<li><code>enumerable</code>：该属性是否可被枚举<code>for...in 、 Object.keys() ...</code>：默认<code>false</code></li>
</ul>
<p><strong>数据描述符特有属性</strong></p>
<ul>
<li><code>value</code>：该属性的值：默认<code>undefined</code></li>
<li><code>writable</code>：是否可被<code>赋值运算符</code>改变：默认<code>false</code></li>
</ul>
<p><strong>存取描述符特有属性</strong></p>
<ul>
<li><code>get</code>：该属性的<code>getter</code>函数</li>
<li><code>setter</code>：该属性的<code>setter</code>函数</li>
</ul>
<h2 id="typeof原理"><a href="#typeof原理" class="headerlink" title="typeof原理"></a>typeof原理</h2><h2 id="instanceof原理"><a href="#instanceof原理" class="headerlink" title="instanceof原理"></a>instanceof原理</h2>

    </div>
  </div>
  <div class="go-up">
  <a href="#" rel="go-top">
    <i class="fas fa-angle-up"></i>
  </a>
</div>

<script src="/js/bootstrap.min.js"></script>
<script src="/js/TweenMax.min.js"></script>
<script src="/js/resizeable.min.js"></script>
<script src="/js/joinable.js"></script>
<script src="/js/xenon-api.min.js"></script>
<script src="/js/xenon-toggles.min.js"></script>
<script src="/js/xenon-custom.min.js"></script>


<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script src="/js/lozad.min.js"></script>


</body>

<script src="/js/footer.js"></script>

</html>
